/*
 * @Description: 标题组件
 * @Author: paddies
 * @Date: 2023-11-16 22:26:42
 * @LastEditors: paddies
 * @LastEditTime: 2024-11-18 10:23:22
 * @FilePath: /luntai-user-app/Users/paddies/Desktop/code/A-team/luntai/shared_components/lib/build-title/buildTitle.dart
 */

import 'package:flutter/material.dart';
import 'package:shared_components/init.dart';

Widget buildTitle(
    {String title = '',
    double fontSize = 16,
    String type = '',
    double paddingTop = 13,
    double paddingBottom = 13,
    double paddingLeft = 15,
    double paddingRight = 8,
    bool required = false,
    Color backgroundColor = Colors.transparent,
    Widget? slotWidget,
    Widget? child,
    Color fontColor = const Color(0xff1c1b1f)}) {
  if (type == 'simple') {
    return buildSimpleTitle(
        title: title,
        fontSize: fontSize,
        type: type,
        paddingTop: paddingTop,
        paddingBottom: paddingBottom,
        paddingLeft: paddingLeft,
        paddingRight: paddingRight,
        required: required,
        backgroundColor: backgroundColor,
        slotWidget: slotWidget,
        child: child,
        fontColor: fontColor);
  }
  return Container(
    width: double.infinity,
    color: backgroundColor,
    height: 50,
    // color: Colors.red,
    child: Row(
      children: [
        Padding(
          padding: EdgeInsets.only(
              top: paddingTop,
              bottom: paddingBottom,
              left: paddingLeft,
              right: paddingRight),
          child: Container(
              width: 4,
              height: double.infinity,
              decoration: BoxDecoration(
                color: sharedManager.themeColor,
                borderRadius: BorderRadius.all(Radius.circular(20.0)), //圆角
              )),
        ),
        required
            ? Text(
                "*",
                style: TextStyle(fontSize: 18, color: Colors.redAccent),
              )
            : Text(""),
        Text(
          title,
          style: TextStyle(
              fontSize: fontSize,
              fontWeight: FontWeight.w600,
              color: fontColor),
        ),
        slotWidget == null ? SizedBox() : slotWidget,
        Expanded(
          child: child == null ? SizedBox() : child,
        )
      ],
    ),
  );
}

buildSimpleTitle(
    {String title = '',
    double fontSize = 16,
    String type = '',
    double paddingTop = 13,
    double paddingBottom = 13,
    double paddingLeft = 15,
    double paddingRight = 8,
    bool required = false,
    Color backgroundColor = Colors.transparent,
    Widget? slotWidget,
    Widget? child,
    Color fontColor = const Color(0xff1c1b1f)}) {
  return Container(
    width: double.infinity,
    color: backgroundColor,
    height: 50,
    padding: EdgeInsets.only(left: paddingLeft),
    child: Row(
      children: [
        // Padding(
        //   padding: EdgeInsets.only(
        //       top: paddingTop,
        //       bottom: paddingBottom,
        //       left: paddingLeft,
        //       right: paddingRight),
        //   child: Container(
        //       width: 4,
        //       height: double.infinity,
        //       decoration: BoxDecoration(
        //         color: sharedManager.themeColor,
        //         borderRadius: BorderRadius.all(Radius.circular(20.0)), //圆角
        //       )),
        // ),
        // required
        //     ? Text(
        //         "*",
        //         style: TextStyle(fontSize: 18, color: Colors.redAccent),
        //       )
        //     : Text(""),
        Row(
          children: [
            Text(
              title,
              style: TextStyle(
                  fontSize: fontSize,
                  fontWeight: FontWeight.w600,
                  color: fontColor),
            ),
            Text(
              required ? "（必选）" : "",
              style: TextStyle(color: Color(0xff666666)),
            )
          ],
        ),

        slotWidget == null ? SizedBox() : slotWidget,
        Expanded(
          child: child == null ? SizedBox() : child,
        ),
      ],
    ),
  );
}
